//
// Created by Semir on 2020/5/11.
//

#include <iostream>

using namespace std;

double PowerRecursive(double base, int exponent) {
    if (exponent == 1) {
        return base;
    }
    double res = PowerRecursive(base, (exponent >> 1));
    res *= res;
    if (exponent % 2 == 1) {
        res *= base;
    }
    return res;
}

double Power(double base, int exponent) {
    if (exponent == 0) {
        return 1;
    }
    if (base == 0) {
        return base;
    }
    bool negative = false;
    if (exponent < 0) {
        exponent = -exponent;
        negative = true;
    }
    double res = PowerRecursive(base, exponent);
    if (negative) {
        res = 1 / res;
    }
    return res;
}


int main() {
    double res = Power(3, 4);
    cout << res << endl;
    return 0;
}
